package edu.sctu.zhuyingzhi.month201506.day20150615.fileOperationV2;

import java.io.IOException;
import java.util.Scanner;

/**
 * Created by Administrator on 2015/6/14.
 */
public class ChioceFunction {
    FileUitl fileUitl = new FileUitl();
    public ChioceFunction() {
        System.out.println("************这是一个对文件进行操作的小程序*******************");
        System.out.println("请选择你需要进行的操作：");
        System.out.println("o:打开文件");
        System.out.println("c:复制文件");
        System.out.println("m:移动文件");
        System.out.println("d:删除文件");
        System.out.println("r:查看文件夹");
        System.out.println("e:退出程序");
    }

    public void functionRun() throws IOException {
        Scanner in = new Scanner(System.in);
        String list;
        String target;
        boolean flag = true;
        String c = in.next();
        while(flag) {

            switch (c) {
                case "o":
                    System.out.println("你所选择的是打开文件");
                    System.out.println("请输入你需要打开的文件目录");
                    list = in.next();
                    fileUitl.openFile(list);
                    c = in.next();
                    break;
                case "c":
                    System.out.println("你所选择的是复制文件");
                    System.out.println("请输入你需要复制文件的目录：");
                    list = in.next();
                    System.out.println("请输入目标文件夹");
                    target = in.next();
                    fileUitl.copyFile(list,target);
                    c = in.next();
                    break;
                case "m":
                    System.out.println("你所选择的是移动文件");
                    System.out.println("请输入你需要移动的文件的目录：");
                    list = in.next();
                    System.out.println("请输入目标文件夹");
                    target = in.next();
                    fileUitl.moveFile(list,target);
                    c = in.next();
                    break;
                case "d":
                    System.out.println("你所选择的是删除文件");
                    System.out.println("请输入你需要删除文件的目录");
                    list = in.next();
                    fileUitl.deleteFile(list);
                    c = in.next();
                    break;
                case "r":
                    System.out.println("你所选择的是查看文件夹");
                    System.out.println("请输入你需要查看文件的目录：");
                    list = in.next();
                    fileUitl.readFile(list);
                    c = in.next();
                    break;
                case "e":
                    System.out.println("你所选择的是退出程序");
                    flag = false;
                    break;
            }
        }
    }
}
